//
//  CollectionViewController.m
//  南京大牌档
//
//  Created by student on 14-1-9.
//  Copyright (c) 2014年 无锡第三团队. All rights reserved.
//

#import "CollectionViewController.h"

@interface CollectionViewController ()

@end

@implementation CollectionViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    collectionFoodArray=[NSMutableArray arrayWithContentsOfFile:[self filePath:@"collectionFood.plist"]];
    collectionTV=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, WXHLApplicationBounds().size.height) style:UITableViewStylePlain];
    collectionTV.dataSource=self;
    collectionTV.delegate=self;
    [self.view addSubview:collectionTV];
	
}

- (NSString*)filePath:(NSString*)fileName {
    NSArray* myPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString* myDocPath = [myPaths objectAtIndex:0];
    NSString* filePath = [myDocPath stringByAppendingPathComponent:fileName];
    return filePath;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return collectionFoodArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifer=@"Cell";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifer];
    if(cell==nil)
    {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;
    }
    [cell.imageView setImageWithURL:[NSURL URLWithString:collectionFoodArray[indexPath.row][5]]];
    cell.textLabel.text=collectionFoodArray[indexPath.row][1];
    
    return cell;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
